<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>修改用户信息</title>
    <meta name="renderer" content="webkit">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="layuiadmin/layui/css/layui.css"   media="all">
    <script src="layuiadmin/layui/layui.js" charset="utf-8"></script>
    <style>
        body{
            padding-top: 20px;
        }
        .layui-input, .layui-textarea {
            width: 90%;
        }
        .layui-form-label {
            padding: 9px 0px;
        }
        .tishi {
            margin-left: 112px;
        }
    </style>
</head>
<body>
<form class="layui-form" >
    <input hidden name="id" th:value="${sysUser.getId()}">
    <div class="layui-form-item">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-block">
            <input type="text" name="username" th:value="${sysUser.getUsername()}" required  lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">手机号</label>
        <div class="layui-input-block">
            <input type="text" name="phone" required th:value="${sysUser.getPhone()}" lay-verify="required" placeholder="请输入手机号" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">新密码</label>
        <div class="layui-input-block">
            <input type="text" name="password" th:value="${sysUser.getPassword()}" required lay-verify="required" placeholder="请输入新密码" autocomplete="off" class="layui-input">
        </div>
        <div class="tishi layui-form-mid layui-word-aux">须含有英文字母和数字且大于10位</div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">人员类型</label>
        <div class="layui-input-block">
            <select name="role" lay-verify="required">
                <option value="1">快递员</option>
                <option value="2">住户</option>
                <option value="3">管理员</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script th:inline="javascript">
    var ctxPath=[[@{/}]];
        layui.use(['laydate','table','form'],function (){
            var  laydate = layui.laydate;
            var table = layui.table;
            var form = layui.form;
            var $ = layui.$;
            laydate.render({
                elem: '[name="birthday"]'
            });
            //表单提交
            form.on('submit(formDemo)', function(data){
                //异步请求提交数据
                var url="/doUpdateUser";
                $.post(url,data.field,function (response){
                    if(response>0){
                        layer.msg('更新成功,请刷新页面', {
                            icon: 1,
                            time: 1000 //2秒关闭（如果不配置，默认是3秒）
                        }, function(){
                            //刷新表格

                            //    提交成功关闭窗口，
                            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            parent.layer.close(index); //再执行关闭
                        });
                    }else{
                        layer.msg('更新失败', {
                            icon: 2,
                            anim: 6
                        })
                    }
                })

                return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
            });
        });
</script>
</body>
</html>
